home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: swampwiz@ix.netcom.com(Jean P. Laborde )
- Newsgroups: comp.lang.c++
- Subject: Re: file descriptors and fstreams...
- Date: 9 Apr 1996 02:42:06 GMT
- Organization: Netcom
- Message-ID: <4kcipu$fe9@dfw-ixnews4.ix.netcom.com>
- References: <4k780i$dd5@beyond.escape.com>
- NNTP-Posting-Host: nor-la5-12.ix.netcom.com
- X-NETCOM-Date: Mon Apr 08 9:42:06 PM CDT 1996
-
- In <4k780i$dd5@beyond.escape.com> ward@escape.com (Christian Ward)
- writes:
- >
- >
- >Hi I'm a very beginner c++ programmer, although I've been doing C for
- a
- >while. I know there's a C function called fdopen which takes a file
- >descriptor and creates a stream for it so you can use fprintf, fscanf,
- >and all that other good stuff. Is there a similar function (or
- whatever)
- >that takes a file descriptor and does something to let you use << and
- >>
- >with it?
- >
- >Like I said I'm very new to C++ and I'm sorry that I don't have the
- >correct terminology for all this stuff.
- >
- >Justin
-
- nice name, Justin - it's my father's middle name.
-
- Try this:
-
-
- #include <iostream.h>
- #include <fstream.h>
- #include <conio.h>
-
- ifstream in("in_file.txt");
- ofstream out("out_file.txt");
-
- int i;
- cout << "Enter an integer" << endl;
- cin >> i;
- cout << endl << "you just entered " << i << endl;
-
- // much nicer than the stupid '%d' stuff & when you really start
- understandin c++, you'll find elegant ways to format as well!
-
- Comments Suggested,
- The Swamp Wizard
-
-
-
-
-